//
//  AppDelegate.m
//  baisibudejie17
//
//  Created by 吴坤金 on 16/10/14.
//  Copyright © 2016年 吴坤金jhgu. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

//显示在最外面，永远是栈顶控制器view
//程序一启动完成就会调用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
//    1.创建窗口
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
//    2.设置窗口根控制器
//    结论：一开始想显示谁，就设置窗口根控制器为谁
    UITabBarController *tabBarVc = [[UITabBarController alloc] init];
    self.window.rootViewController = tabBarVc;
//    2.1添加tabBarVc子控制器 =》用多少个按钮就有多少子控制器
//    精华
   UIViewController *vc = [[UIViewController alloc] init];
    vc.view.backgroundColor = [UIColor blueColor];
//    创建导航控制器 =》VC
//    initWithRootViewController => Push
   UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
//    添加tabBarVC的子控制器
//    tabBarVc:默认会把第0个子控制器的view添加自己存放子控制器的view
    [tabBarVc addChildViewController:nav];
    
//    新帖
    UIViewController *vc1 = [[UIViewController alloc] init];
    vc1.view.backgroundColor = [UIColor orangeColor];
//    创建导航控制器 =》 VC
   UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:vc1];
    [tabBarVc addChildViewController:nav1];
    
    
//    发布：不是导航控制器
    UIViewController *vc2 = [[UIViewController alloc] init];
    vc2.view.backgroundColor = [UIColor purpleColor];
//    添加tabBarVC的子控制器
//    tabBarVC：默认会把第0个子控制器的View添加存放子控制器的view
//    tabBarVC切换原理：移除上一个子控制器的view，把当前子控制器的view
    [tabBarVc addChildViewController:vc2];
    
//    关注
    UIViewController *vc3 = [[UIViewController alloc] init];
    vc3.view.backgroundColor = [UIColor magentaColor];
//    创建导航控制器 =》VC
    UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:vc3];
    
//    添加tabBarVc的子控制器
//    tabBarVC：默认会把第0个子控制器的view添加自己存放子控制器的view
    [tabBarVc addChildViewController:nav3];
    
//    我
    UIViewController *vc4 = [[UIViewController alloc] init];
    vc4.view.backgroundColor = [UIColor brownColor];
//    创建导航控制器 =》VC
   UINavigationController *nav4 = [[UINavigationController alloc] initWithRootViewController:vc4];
    [tabBarVc addChildViewController:nav4];
//    3.显示主窗口
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
